﻿using Slex;
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace CaseMap {
    public class Layout {
        UserControl container;
        internal UserControl Container {
            get { return container; }
            set { container = value; container.Content = backgrountpanel; }
        }
        #region area
        internal Area backgrountpanel;
        internal Area layoutroot;
        public object DataContext { get { return layoutroot.DataContext; } set { layoutroot.DataContext = value; } }
        #endregion

        
        internal Layout(double leftright = 30d, double topbottom = 10d, double opacity = .85d, Brush b = null) {
            this.layoutroot = new Area { Margin = new Thickness(leftright, topbottom, leftright, topbottom), Opacity = opacity, Background = b ?? new SolidColorBrush(Colors.White) };
            this.backgrountpanel = new Area { Margin = new Thickness(0), HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch };
            this.backgrountpanel.Children.Add(layoutroot);
        }
        public void Reset(double leftright = 30d, double topbottom = 10d, double opacity = .85d, Brush b = null) {
            this.layoutroot.Margin = new Thickness(leftright, topbottom, leftright, topbottom);
            this.layoutroot.Opacity = opacity;
            this.layoutroot.Background = b ?? new SolidColorBrush(Colors.White);
            this.layoutroot.RemoveAll();
        }
        public Brush Background { get { return backgrountpanel.Background; } set { backgrountpanel.Background = value; } }
        static Layout _obj;
        public static Layout Current { get { if (_obj == null)_obj = new Layout(); return _obj; } }      
    }
}
